package com.gemserk.infraestructure.lwjglmavenizer;

import java.io.StringWriter;
import groovy.xml.MarkupBuilder;

public class POMBuilder {

	def buildPom(def mavenId, def classifiers, def lasdependencies){
	

		def writer = new StringWriter()
		def xml = new MarkupBuilder(writer);


		def printMavenId = {builder, theMavenId ->
			builder.groupId(theMavenId.groupId)
			builder.artifactId(theMavenId.artifactId)
			builder.version(theMavenId.version)
		}
		
		
		

		xml.project(){
			modelVersion("4.0.0")
			printMavenId(delegate,mavenId)
//			groupId(mavenId.groupId)
//			artifactId(mavenId.artifactId)
//			version(mavenId.version)
			description("Library mavenized with LWJGLMavenizer")
			dependencies(){
				classifiers.each { elClassifier ->
					dependency(){
						printMavenId(delegate,mavenId)
						classifier(elClassifier)
					}		
				}
				lasdependencies?.each{ laDependencie ->
					dependency(){
						printMavenId(delegate,laDependencie)				
					}
				}
			}
		}

		return writer.toString();

	}
	
}